<!DOCTYPE html>
<html lang="zh">
<head>
    <title>配置组管理 - virus CMS</title>
    {include file="common/meta" /}
</head>
<body>

<!-- Navbar -->
{include file="common/header" /}
<!-- /Navbar -->
<!-- Main Container -->
<div class="main-container container-fluid">
    <!-- Page Container -->
    <div class="page-container">

        <!-- Page Sidebar -->
        {include file="common/sidebar" /}
        <!-- /Page Sidebar -->
        <!-- Page Content -->
        <div class="page-content">
            <!-- Page Breadcrumb -->
            <div class="page-breadcrumbs">
                <ul class="breadcrumb">
                    <li class="active">
                        <i class="fa fa-home"></i>&nbsp;控制面板
                    </li>
                    <li>
                        <i class="fa fa-cogs"></i> 常规管理
                    </li>
                    <li>
                        <i class=""></i> 配置组管理
                    </li>
                </ul>
            </div>
            <!-- /Page Breadcrumb -->
            <!-- Page Body -->
            <div class="page-body">
                {if condition="check_auth('ConfigGroup/create')"}
                <a href="{:url('ConfigGroup/create')}" class="btn btn-sm btn-primary"><i class="fa fa-plus"></i>&nbsp;添加配置组</a>
                {/if}
                <div class="row">
                    <div class="col-xs-12">
                        <div class="widget">
                            <div class="widget-header">
                                <span class="widget-caption">配置组列表</span>
                                <div class="widget-buttons">
                                    {$list->render()|raw}
                                </div>
                            </div>
                            <div class="widget-body">
                                <table class="table table-hover table-bordered table-responsive">
                                    <thead>
                                    <tr>
                                        <th>#ID</th>
                                        <th>配置组变量</th>
                                        <th>配置组标题</th>
                                        <th>创建时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {foreach $list as $v}
                                    <tr>
                                        <td>{$v.id}</td>
                                        <td>{$v.group_name}</td>
                                        <td>{$v.group_title}</td>
                                        <td>{$v.create_time}</td>
                                        <td>
                                            {if condition="check_auth('ConfigGroup/edit')"}
                                            <a href="{:url('ConfigGroup/edit', array('id' => $v.id))}"
                                               class="btn btn-primary"><i class="fa fa-edit"></i>编辑</a>
                                            {/if}
                                            {if condition="check_auth('ConfigGroup/delete')"}
                                            <a href="javascript:;" data-id="{$v.id}"
                                               onclick="confirm_msg(this, '你确定要删除吗?');" class="btn btn-danger">
                                                <i class="fa fa-trash"></i>删除
                                            </a>
                                            {/if}
                                            {if condition="check_auth('ConfigGroup/param')"}
                                            <a href="{:url('ConfigGroup/param', array('id' => $v.id))}" class="btn btn-warning">
                                                <i class="fa fa-leaf"></i> 参数列表
                                            </a>
                                            {/if}
                                        </td>
                                    </tr>
                                    {/foreach}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->

    </div>
    <!-- /Page Container -->
    <!-- Main Container -->

</div>

{include file="common/script" /}
<script type="text/javascript">
    //确认删除
    function confirm_msg(obj, msg = '') {
        var id = $(obj).attr('data-id');
        var url = "/admin/ConfigGroup/delete";
        confirm(msg, "你将失去这条数据", function (isConfirm) {
            if (isConfirm) {
                $.post(url, {id: id}, function (data) {
                    if (data.code === 1) {
                        alert(data.msg, ":)", function () {
                            setTimeout(function () {
                                location.href = '/admin/ConfigGroup/index';
                            }, 2000);
                        }, {type: 'success', confirmButtonText: 'OK'});
                    } else {
                        alert(data.msg, ":)", function () {
                            setTimeout(function () {
                                location.href = '/admin/ConfigGroup/index';
                            }, 2000);
                        }, {type: 'error', confirmButtonText: 'OK'});
                    }
                }, 'json');
            } else {
                return false;
            }
        }, {confirmButtonText: '确定', cancelButtonText: '取消', width: 400});
    }
</script>
</body>
<!--  /Body -->
</html>
